package com.dingwen.treasure.mybatisplus.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dingwen.treasure.model.entity.mybatisplus.SysElement;
import com.dingwen.treasure.mybatisplus.mapper.SysElementMapper;
import com.dingwen.treasure.mybatisplus.service.SysElementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dingwen
 * @description 针对表【sys_element(页面元素表)】的数据库操作Service实现
 * @createDate 2022-06-20 17:18:19
 */
@Service
@DS("slave")
public class SysElementServiceImpl extends ServiceImpl<SysElementMapper, SysElement> implements SysElementService {

    /**
     * sysElementMapper
     */
    @Resource
    private SysElementMapper sysElementMapper;

    /**
     * 按用户id获取系统元素
     *
     * @param userId 用户id
     * @return {@link List}<{@link SysElement}>
     */
    @Override
    public List<SysElement> getSysElementsByUserId(Long userId) {
        return sysElementMapper.getSysElementsByUserId(userId);
    }

    /**
     * 按角色ID和菜单ID获取系统元素
     *
     * @param roleIds 角色ID
     * @param menuIds 菜单ID
     * @return {@link List}<{@link SysElement}>
     */
    @Override
    public List<SysElement> getSysElementsByRoleIdsAndMenuIds(List<Long> roleIds, List<Long> menuIds) {
        return sysElementMapper.getSysElementsByRoleIdsAndMenuIds(roleIds, menuIds);
    }

}




